#ifndef _IntersectResult_H_
#define _IntersectResult_H_

#pragma once
#include "LightingRender.h"

class Primitive;

class IntersectResult {
public:
	const Primitive *primitive = nullptr;
	Double distance = 0;
	Vector3 position;
	Vector3 normal;
	Vector2 uv;

	IntersectResult() {};
	~IntersectResult() {};

	inline Vector3 getReflectNormal(const Vector3 &rayDir) const;

	inline void operator=(const IntersectResult &result);
	inline void clear();

	string str() const;
};

inline Vector3 IntersectResult::getReflectNormal(const Vector3 &rayDir) const {
	return (normal * rayDir > 0) ? -normal : normal;
}

inline void IntersectResult::operator=(const IntersectResult &result) {
	primitive = result.primitive;
	distance = result.distance;
	position = result.position;
	normal = result.normal;
	uv = result.uv;
}

inline void IntersectResult::clear() {
	primitive = nullptr;
}

#include "Primitive.h"

#endif // _IntersectResult_H_